package com.hung.tripleprovider.service;

import com.hung.triple.ResultDTO;
import com.hung.triple.bootstrap.annotation.TripleProvider;
import com.hung.tripleprovider.api.HelloService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author Hung
 * @date 2022/9/24 15:14
 */
@Service
@TripleProvider(interfaceClass = HelloService.class)
@Slf4j
public class HelloServiceImpl implements HelloService {

    @Override
    public ResultDTO<String> sayHello(String msg, long time) {

        log.info("=== provider ===");
        log.info("msg = " + msg);
        log.info("time = " + time);

        if ("EXCEPTION".equals(msg)) {
            throw new RuntimeException("this is a exception");
        }

        String res = "接受消息:" + msg + "耗时:" + (System.currentTimeMillis() - time);
        return ResultDTO.success(res);
    }
}